import org.codehaus.groovy.grails.commons.ConfigurationHolder

import com.jeff.Airline
import com.jeff.Book
import com.jeff.City
import com.jeff.User
import com.jeff.transaction.Credit

class BootStrap {

    def init = { servletContext ->
		//create init data when server start up...
		new Book(title:"Oddessy", author:"Jeff").save(failOnError:true)
		new Book(title:"Larry", author:"Bird").save(failOnError:true)
		
		new User(email:"jeff@leo.com", password:"1234").save(failOnError:true)
		
		new City(name:"Singapore",code:"SG").save(failOnError:true)
		
		new Airline(name:"Singapore Airline",code:"SQ").save(failOnError:true)
		new Airline(name:"China Airline",code:"CA").save(failOnError:true)
		new Airline(name:"Tiger Airline",code:"TA").save(failOnError:true)
		
		new Credit(value:123.0).save(failOnError:true)
		
		testConfRead()
		
//		org.hsqldb.util.DatabaseManager.main()
    }
	
    def destroy = {
    }
	
	def testConfRead() {
		assert 315==ConfigurationHolder.config.appl.conf.demo //assertion passed
	}
}
